<?php
namespace Admin\Controller;
use Think\Controller;
class AdminCommonController extends Controller {
	function _initialize(){
        if(!session('ADMIN_ID')){
            $this -> error("请先登录", U('Login/index'));
        }
		$Auth = new \Think\Auth();
		$module_name=CONTROLLER_NAME.'/'.ACTION_NAME;
		//以用户名来判断是否是超级管理员，绕过验证
        if($_SESSION[C('AUTH_KEY')]==C('ADMIN_AUTH_KEY')){    
            return true;
        }
        if(!$Auth->check($module_name,$_SESSION[C('AUTH_KEY')])){
            $this->error('没有权限');
        }
	}
	//注册rule规则
	public function register() {
		$class_name = get_class($this);
		return register($class_name);
	}
	
	
}